package user;

import model.FIFOBuffer;
import model.Stage;

/**
 * Demonstration how to build a pipe with single modules
 *
 */
public class PipeDemonstrator {

	public static void main(String[] args) {
		// Connection between Stages
		FIFOBuffer c0 = new FIFOBuffer();
		FIFOBuffer c1 = new FIFOBuffer();
		FIFOBuffer c2 = new FIFOBuffer();
		FIFOBuffer c3 = new FIFOBuffer();
		FIFOBuffer c4 = new FIFOBuffer();

		// Stages/Workers with connections and assigned task
		Stage w0 = new Stage(0, null, c0, new TaskReadText(
				"../Pipe/src/wortlist.txt"));
		System.out.println(w0.isStageAlive());
		Stage w1 = new Stage(1, c0, c1, new TaskOutputText(System.out));
		Stage w2 = new Stage(2, c1, c2, new TaskToUpper());
		Stage w3 = new Stage(3, c2, c3, new TaskOutputText(System.out));
		Stage w4 = new Stage(4, c3, c4, new TaskHashCode());
		Stage w5 = new Stage(5, c4, null, new TaskOutputHash(System.out));

		// clear up threads
		if (!w0.isStageAlive())
			w0.stopStage();
		if (!w1.isStageAlive())
			w1.stopStage();
		if (!w2.isStageAlive())
			w2.stopStage();
		if (!w3.isStageAlive())
			w3.stopStage();
		if (!w4.isStageAlive())
			w4.stopStage();
		if (!w5.isStageAlive())
			w5.stopStage();
		
		
		
		
		
		
		
	}

}
